import { NextRequest, NextResponse } from 'next/server'
import { ChatClient } from 'dify-client'
import { API_KEY, API_URL, APP_ID } from '@/config'


const userPrefix = `user_${APP_ID}:`

export const getInfo = (request: NextRequest) => {

    const token = request.cookies.get('token')?.value
    const user = request.cookies.get('user')?.value
    return {
        token,
        user,
    }
}

export const setSession = (token: string) => {
    return { 'Set-Cookie': `token=${token};path=/` }
}

export const client = new ChatClient(API_KEY, API_URL || undefined)
